package com.ffe.flower.engine.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.persistence.Version;

@Entity
@Table(name = "FLOW_INFO")
public final class FlowInfo {

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name = "FLOW_ID")
  private Integer flowId;

  @Column(name = "PROCESS_ID", length = 100, nullable = false)
  private String processId;

  @Column(name = "APPLICANT_ID", length = 50, nullable = false)
  private String applicantId;

  @Column(name = "TARGET_ID", length = 50, nullable = false)
  private String targetId;

  @Column(name = "PROMOTER_ID", length = 32, nullable = false)
  private String promoterId;

  @Column(name = "PROMOTER_AGENT", nullable = false)
  private boolean promoterAgent;

  @Column(name = "CUR_STATE_ID")
  private Integer curStateId;

  @Enumerated(EnumType.STRING)
  @Column(name = "CUR_STATE", length = 20)
  private Enum<?> curState;

  @Column(name = "FINISHED", nullable = false)
  private boolean finished;

  @Column(name = "THROUGHOUT", nullable = false)
  private boolean throughout;

  @Column(name = "CREATED_DATE", nullable = false)
  private Date createdDate;

  @Column(name = "LAST_MODIFIED_DATE", nullable = false)
  private Date lastModifiedDate;

  @Version
  private long version;

  @PrePersist
  public void onPrePresist() {
    this.createdDate = this.lastModifiedDate = new Date();
  }

  @PreUpdate
  public void onPreUpdate() {
    this.lastModifiedDate = new Date();
  }

  public Date getLastModifiedDate() {
    return lastModifiedDate;
  }

  public void setLastModifiedDate(Date lastModifiedDate) {
    this.lastModifiedDate = lastModifiedDate;
  }

  public String getApplicantId() {
    return applicantId;
  }

  public void setApplicantId(String applicantId) {
    this.applicantId = applicantId;
  }

  public String getTargetId() {
    return targetId;
  }

  public void setTargetId(String targetId) {
    this.targetId = targetId;
  }

  public Integer getFlowId() {
    return flowId;
  }

  public void setFlowId(Integer flowId) {
    this.flowId = flowId;
  }

  public Integer getCurStateId() {
    return curStateId;
  }

  public void setCurStateId(Integer curStateId) {
    this.curStateId = curStateId;
  }

  public Enum<?> getCurState() {
    return curState;
  }

  public void setCurState(Enum<?> curState) {
    this.curState = curState;
  }

  public boolean isFinished() {
    return finished;
  }

  public void setFinished(boolean finished) {
    this.finished = finished;
  }

  public boolean isThroughout() {
    return throughout;
  }

  public void setThroughout(boolean throughout) {
    this.throughout = throughout;
  }

  public Date getCreatedDate() {
    return createdDate;
  }

  public void setCreatedDate(Date createdDate) {
    this.createdDate = createdDate;
  }

  public String getPromoterId() {
    return promoterId;
  }

  public void setPromoterId(String promoterId) {
    this.promoterId = promoterId;
  }

  public boolean isPromoterAgent() {
    return promoterAgent;
  }

  public void setPromoterAgent(boolean promoterAgent) {
    this.promoterAgent = promoterAgent;
  }

  public String getProcessId() {
    return processId;
  }

  public void setProcessId(String processId) {
    this.processId = processId;
  }

}
